qx.Class.define("rocketspocket.ui.yahoo.YahooWindow",
{
	extend : qx.ui.window.Window,
	construct : function()
	{
		this.base(arguments, this.tr("Test Data Binding"));
		this.__initLayout();
	},
	events :
	{
		"reload" : "qx.event.type.Event",
		"post" : "qx.event.type.Data"
	},
	members :
	{
		__initLayout : function(){
			this.setShowMaximize(false);
			this.setShowMinimize(false);
			
			this.setWidth(260);
			this.setHeight(600);
			
			var layout = new qx.ui.layout.Grid(0, 0);
			this.setLayout(layout);
			
			// toolbar
			var toolbar = new qx.ui.toolbar.ToolBar();
			this.add(toolbar, {row: 0, column: 0, colSpan: 2});
			
			// reload button
			var reloadButton = new qx.ui.toolbar.Button(this.tr("Reload"));
			reloadButton.addListener("execute", function() {
				this.fireEvent("reload");
			}, this)
			toolbar.add(reloadButton);
			
			// spacer
			toolbar.addSpacer();
			// settings button
			var settingsWindow = null;
			var settingsButton = new qx.ui.toolbar.Button(this.tr("Preferences"));
			toolbar.add(settingsButton);
			settingsButton.setToolTipText(this.tr("Change the applications settings."));
			settingsButton.addListener("execute", function() {
				if (!settingsWindow) {
					settingsWindow = new rocketspocket.ui.twitter.SettingsWindow();
					settingsWindow.moveTo(720,30);
				}
				settingsWindow.open();
			}, this);
			
			// create the model data
//			var rawData = [];
//			for (var i = 0; i < 2500; i++) {
//			 rawData[i] = "Item No " + i;
//			}
//			var jsonData = {
//			     "firstName": "John",
//			     "lastName" : "Smith",
//			     "age"      : 25,
//			     "address"  :
//			     {
//			         "streetAddress": "21 2nd Street",
//			         "city"         : "New York",
//			         "state"        : "NY",
//			         "postalCode"   : "10021"
//			     },
//			     "phoneNumber":
//			     [
//			         {
//			           "type"  : "home",
//			           "number": "212 555-1234"
//			         },
//			         {
//			           "type"  : "fax",
//			           "number": "646 555-4567"
//			         }
//			     ]
//			 };
//			var jsonData = {
//  "items": [
//    {"name": "a", "type": "media-video"},
//    {"name": "b", "type": "office-calendar" },
//    {"name": "c", "type": "media-audio" },
//    {"name": "d", "type": "office-presentation" },
//    {"name": "e", "type": "office-document" },
//    {"name": "f", "type": "archive" },
//    {"name": "g", "type": "media-audio" },
//    {"name": "h", "type": "text-html" },
//    {"name": "i", "type": "media-image" },
//    {"name": "j", "type": "office-spreadsheet" },
//    {"name": "k", "type": "executable" },
//    {"name": "l", "type": "office-contact" },
//    {"name": "m", "type": "text-html" },
//    {"name": "n", "type": "text-plain" },
//    {"name": "o", "type": "executable" },
//    {"name": "p", "type": "text-plain" },
//    {"name": "q", "type": "office-illustration" },
//    {"name": "r", "type": "office-contact" },
//    {"name": "s", "type": "office-spreadsheet" },
//    {"name": "t", "type": "office-presentation" },
//    {"name": "u", "type": "media-video" },
//    {"name": "v", "type": "office-calendar" },
//    {"name": "w", "type": "office-document" },
//    {"name": "x", "type": "archive" },
//    {"name": "y", "type": "office-illustration" },
//    {"name": "z", "type": "media-image" }
//  ]
//};
			var url = "http://demo.qooxdoo.org/1.6/demobrowser/resource/demobrowser/demo/data/list.json";
//			var url = "http://api.twitter.com/1/statuses/public_timeline.json";
			var store = new qx.data.store.Json(url);
//			var model = qx.data.marshal.Json.createModel(jsonData);
			
			// create the list
			var list = new qx.ui.list.List();
			var controller = new qx.data.controller.List(null , list);
			controller.setLabelPath("name");
      // set a converter for the icons
      controller.setIconOptions({converter : function(data) {
        return "icon/16/mimetypes/" + data + ".png";
      }});
      // set the name of the icon property
      controller.setIconPath("type");
			store.bind("model.items", controller, "model");
			// configure the lists's behavior
//			var delegate = {
//			  sorter : function(a, b) {
//			    return a > b ? 1 : a < b ? -1 : 0;
//			  }
//			};
//			list.setDelegate(delegate);
			
			// Pre-Select "Item No 20"
//			list.getSelection().push(model.getItem(20));
			
			// log selection changes
//			list.getSelection().addListener("change", function(e) {
//			  this.debug("Selection: " + list.getSelection().getItem(0));
//			}, this);
			this.add(list, {row: 1, column: 0, colSpan: 2});
			this.setContentPadding(0);
			layout.setRowFlex(1, 1);
			layout.setColumnFlex(0, 1);
		}
	}
});